package com.elitel.common.businessJdbc.oracle;

import java.sql.PreparedStatement;

import com.elitel.common.businessJdbc.BusinessGeneralPreparedStatementStrategy;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class OraclePreparedStatementStrategy extends BusinessGeneralPreparedStatementStrategy{

    @Override
    public boolean matchPreparedStatementSetMethodByFieldType(PreparedStatement ps, int parameterIndex, Object columnValue, String fieldType) throws Exception{
        if(super.matchPreparedStatementSetMethodByFieldType(ps, parameterIndex, columnValue, fieldType)){
            return MATCH_SUCCESS;
        }

        // here handle specific type
        if(isContainLeastOneString(fieldType, "string")){
            ps.setString(parameterIndex, columnValue.toString());
        }else{
            ps.setString(parameterIndex, columnValue.toString());
            return MATCH_FAIL;
        }
        return MATCH_SUCCESS;
    }
}
